import Api from '@/api/server/member'
import i18n from "@/lang/index";
const modalConfig = {
  pageName: 'sys:user',
  dialog: {
    title: i18n.global.t("title.33"),
    width: 800,
    appendToBody: true,
    draggable: true,
    labelWidth: "auto",
  },
  formAction: (data) => {
    console.log('edit', data)
    return new Promise((resolve, reject) => {
      Api.put(data).then((s) => {
        console.log(s)
        resolve(s)
      }).catch((e) => {
        reject(e)
      })
    })
  },
  formItems:  [
    {
      type: "input",
      label: "ID",
      prop: "id",
      attrs: {
        disabled: true
      },
      hidden: true,
    },
    {
      type: "input",
      label: i18n.global.t("label.15"),
      prop: "user_id",
      attrs: {
        placeholder: i18n.global.t("hint.156"),
        disabled: true
      },
      col: {
        span: 12,
      }
    },
    {
      type: "select",
      label: i18n.global.t("label.45"),
      prop: "role",
      options: [
        { label: i18n.global.t("label.158"), value: 'user' },
        { label: i18n.global.t("label.167"), value: 'admin' },
        { label: i18n.global.t("label.159"), value: 'bot' },
      ],
      col: {
        span: 12,
      }
    },
    {
      type: "input",
      label: i18n.global.t("label.154"),
      prop: "conversation_id",
      attrs: {
        placeholder: i18n.global.t("hint.157"),
      },
      col: {
        span: 12,
      }
    },
    {
      type: "radio",
      label: i18n.global.t("label.157"),
      prop: "can_send_group_messages",
      options: [
        { label: i18n.global.t("status.2"), value: false },
        { label: i18n.global.t("status.1"), value: true },
      ],
      initialValue: false,
      col: {
        span: 12,
      }
    },
    {
      type: "radio",
      label: i18n.global.t("label.156"),
      prop: "can_message_participants",
      options: [
        { label: i18n.global.t("status.2"), value: false },
        { label: i18n.global.t("status.1"), value: true },
      ],
      initialValue: false,
      col: {
        span: 12,
      }
    },
    {
      type: "radio",
      label: i18n.global.t("label.155"),
      prop: "is_banned",
      options: [
        { label: i18n.global.t("status.2"), value: 0 },
        { label: i18n.global.t("status.1"), value: 1 },
      ],
      initialValue: 0,
      col: {
        span: 12,
      }
    },
    {
      type: "input",
      label: i18n.global.t("label.14"),
      prop: "note",
      attrs:{
        type:"textarea",
        rows:4
      },
      col: {
        span: 24,
      }
    },
  ],
  formRules: {
    user_id: [{ required: true, message: i18n.global.t("hint.156"), trigger: "blur" }],
    conversation_id: [{ required: true, message: i18n.global.t("hint.157"), trigger: "blur" }],
    role: [{ required: true, message: i18n.global.t("hint.158"), trigger: ['change', 'blur'] }],
  },
}

export default modalConfig
